home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / earcd / util / dir / managers.lha / Managers / Dir / Dir.gc < prev    next >
Text File  |  1997-01-15  |  7KB  |  298 lines

  1. G4C
  2.  
  3. ; This is a Full blown File Manager.
  4.  
  5. ; I know it's difficult to follow specially since it consists
  6. ; of many GUIs which open-close on their own, but.. hey, it's
  7. ; a tough world out there..
  8.  
  9. ; The main variable used is "lv_file", which is the name of the
  10. ; variable where both listviews will store the files selected.
  11.  
  12. ; Get the full archive of Gui4Cli (Aminet:Dev/Gui/Gui4Cli.lha),
  13. ; read the guide and construct the file manager of your dreams! 
  14.  
  15.  
  16. WinBig 20 30 200 200 Devices
  17. WinType 11110001
  18.  
  19.  
  20. xOnLoad
  21. setvar fm_mode 1
  22. setgad Dir.gc 2 HIDE            ; hide the gadgets of the
  23. setgad Dir.gc 10 HIDE            ; other half of the window
  24. setgad Dir.gc 11 HIDE
  25. setgad Dir.gc 12 HIDE
  26. setgad Dir.gc 13 HIDE
  27. setgad Dir.gc 14 HIDE
  28. setgad Dir.gc 15 HIDE
  29. setgad Dir.gc 16 HIDE
  30. setgad Dir.gc 17 HIDE
  31. guiopen Dir.gc
  32. guiload :dir.cli
  33. guiload :Dir.g                ; load the helper guis
  34. guiload :Dir.view            ; auto view function
  35. guiload :dir.prefs            ; the default viewers
  36. setvar lv_fmscreen ""            ; start by opening on WB
  37. setvar lvd_all       none        ; set our variables
  38. setvar lv_dir1  ""
  39. setvar lv_dir2  ""
  40. setvar lv_current 1
  41. rtn.option = ''
  42.  
  43. xonquit
  44. guiquit Dir.g            ; quit our other guis also
  45. guiquit dir.view
  46. guiquit Dir.g2
  47. guiquit Dir.g3
  48. guiquit dir.g4
  49. guiquit dir.gv
  50. guiquit dir.cli
  51. guiquit dir.prot
  52. guiquit dir.user
  53. delvar  lv_#?                   ; and delete *all* our variables
  54. delvar  mlv_#?
  55.  
  56. xOnOpen
  57. SetGad dir.gc 20 OFF
  58.  
  59. xOnClose 
  60. SetGad dir.gc 20 ON
  61.  
  62.  
  63. xAppIcon 0 0 :dir.gc DIR.gc lv_app OFF
  64. GadID 20
  65. GuiOpen dir.gc
  66. GuiScreen dir.gc FRONT
  67. if $lv_app > " "
  68.    gosub dir.gc appdir 
  69. endif
  70.  
  71.  
  72. xAppWindow  lv_app                 ; The FM is also an AppWindow
  73. gosub dir.gc appdir                ; going to the dir of the icon..
  74.  
  75.  
  76. xroutine appdir
  77. setvar lv_current 1
  78. ifexists DIR $lv_app               ; see what you have to do when you
  79.     lvdir dir.gc 1 #$lv_app        ; don't have OR..
  80.     setwintitle dir.gc '$lv_app                                 '
  81.     setvar lv_dir1 $lv_app
  82.     stop
  83. endif
  84. ifexists DOS $lv_app
  85.     lvdir dir.gc 1 #$lv_app
  86.     setwintitle dir.gc '$lv_app                                 '
  87.     setvar lv_dir1 $lv_app
  88.     stop
  89. endif
  90. ifexists FILE $lv_app
  91.     extract lv_app PATH lv_app2
  92.     lvdir dir.gc 1 #$lv_app2
  93.     setwintitle dir.gc '$lv_app2                                 '
  94.     setvar lv_dir1 $lv_app2
  95.     extract lv_app FILE lv_app2
  96.     lvfind dir.gc 1 $lv_app2
  97.     stop
  98. endif
  99.  
  100. xOnRMB
  101. guiopen Dir.g        ; This has the copy, delete etc functions
  102.  
  103. xOnJump lv_newscreen            ; If the user jumps screens
  104. setscreen Dir.g $lv_newscreen        ; we have to make the other GUIs
  105. setscreen Dir.g2 $lv_newscreen        ; follow also..
  106. setscreen Dir.g3 $lv_newscreen
  107. setscreen Dir.g4 $lv_newscreen
  108. setscreen Dir.gv $lv_newscreen
  109. setscreen dir.cli $lv_newscreen
  110. setscreen dir.user $lv_newscreen
  111. setvar lv_fmscreen $lv_newscreen        ; the load-when-needed guis need it.
  112.  
  113.  
  114. ;========================= The Directory ListViews ==================
  115. ; Note they both have Hooks which are used to store the current dir
  116. ; name to a variable and display it to the user.
  117.  
  118. ;---------> the left side
  119.  
  120. xListView 0 0 185 0 "" lv_file "" 10 DIR
  121. gadid 1
  122. lvdirhook 1
  123. GadFont topaz.font 8 000        ; CHANGE THIS TO THE FONT YOU LIKE!
  124. ;LVColors   2 1 3 2
  125. guiopen Dir.g2
  126.  
  127. xLVDirHook 1
  128. setvar lv_dir1 $$LV_DIR        ; store the current directory name
  129. setvar lv_current 1
  130. setwintitle Dir.gc '$lv_dir1                                          '   ; show it in the wintitle
  131.  
  132. ;----------> the right side
  133.  
  134. xListView 200 14 185 186 "" lv_file "" 10 DIR
  135. gadid 2
  136. lvdirhook 2
  137. GadFont topaz.font 8 000        ; CHANGE THIS TO THE FONT YOU LIKE!
  138. guiopen Dir.g2
  139.  
  140. xLVDirHook 2
  141. setvar lv_dir2 $$LV_DIR        ; store the current directory name
  142. setvar lv_current 2
  143. update Dir.gc 10 $lv_dir2       ; show it in xTextIn gadget below
  144.  
  145. xTextIn 200 0 185 14 "" lv_dir2 "" 140
  146. gadid 10
  147. GadFont topaz.font 8 000
  148. LVDir Dir.gc 2 #$lv_dir2    ; you can change the dir from here
  149. setvar lv_current 2
  150.  
  151. ;======================== The Action buttons ==========================
  152.  
  153. ;--------> for the left side (source)
  154.  
  155. xButton 185 0 15 15 P
  156. LVDir Dir.gc 1 parent
  157. setvar lv_dir1 $$LV_DIR
  158. setwintitle Dir.gc '$lv_dir1                                        '
  159.  
  160. xButton 185 15 15 15 R
  161. LVDir Dir.gc 1 Root
  162. setvar lv_dir1 $$LV_DIR
  163. setwintitle Dir.gc '$lv_dir1                                        '
  164.  
  165. xButton 185 30 15 15 D
  166. LVDir Dir.gc 1 Disks
  167. setvar lv_dir1 ""
  168. setwintitle Dir.gc 'Devices'
  169.  
  170. xButton 185 45 15 15 A
  171. LVDir Dir.gc 1 All
  172.  
  173. xButton 185 60 15 15 N
  174. LVDir Dir.gc 1 None
  175.  
  176. xButton 185 155 15 15 R
  177. lvdir Dir.gc 1 Refresh
  178.  
  179. xButton 185 170 15 15 <            ; move list left
  180. lvmove Dir.gc 1 -10
  181.  
  182. xButton 185 185 15 15 >
  183. lvmove Dir.gc 1 10
  184.  
  185. ;---------> for the right side (destination) give gadID so we set them on/off
  186.  
  187. xButton 385 0 15 15 P
  188. GadID 11
  189. LVDir Dir.gc 2 parent
  190. setvar lv_dir2 $$LV_DIR
  191. update Dir.gc 10 $lv_dir2
  192.  
  193. xButton 385 15 15 15 R
  194. gadid 12
  195. LVDir Dir.gc 2 Root
  196. setvar lv_dir2 $$LV_DIR
  197. update Dir.gc 10 $lv_dir2
  198.  
  199. xButton 385 30 15 15 D
  200. gadid 13
  201. LVDir Dir.gc 2 Disks
  202. setvar lv_dir2 ""
  203. update Dir.gc 10 ""
  204.  
  205. xButton 385 45 15 15 A
  206. gadid 14
  207. LVDir Dir.gc 2 All
  208.  
  209. xButton 385 60 15 15 N
  210. gadid 15
  211. LVDir Dir.gc 2 None
  212.  
  213. xButton 385 155 15 15 R
  214. lvdir Dir.gc 2 Refresh
  215.  
  216. xButton 385 170 15 15 <        ; move list left
  217. GadID 16
  218. lvmove Dir.gc 2 -10
  219.  
  220. xButton 385 185 15 15 >        ; move list right
  221. GadID 17
  222. lvmove Dir.gc 2 10
  223.  
  224. ;---------> open full file manager
  225.  
  226. xButton 185 90 15 15 >
  227. gadid 21
  228. if $fm_mode = 1
  229.    gosub Dir.gc OpenWindow
  230. else
  231.    gosub Dir.gc CloseWindow
  232. endif
  233.  
  234.  
  235. ;--------> button to switch left <-> right lvs
  236.  
  237. xButton 185 105 15 15 x
  238. gadid  20
  239. setvar lv_temp  $lv_dir2        ; exchange the var names
  240. setvar lv_dir2 $lv_dir1
  241. setvar lv_dir1 $lv_temp
  242. LVDir Dir.gc 1 #$lv_dir1        ; update the listviews
  243. setwintitle Dir.gc '$lv_dir1                                      ' ; and their dir displays
  244. LVDir Dir.gc 2 #$lv_dir2
  245. update Dir.gc 10 $lv_dir2
  246. delvar lv_temp
  247.  
  248. ;--------> same directories
  249.  
  250. xButton 185 120 15 15 =
  251. if $$LV_ID = 1
  252.    lvdir dir.gc 2 #$lv_dir1
  253.    lv_dir2 = $lv_dir1
  254.    update Dir.gc 10 $lv_dir2
  255. else
  256.    lvdir dir.gc 1 #$lv_dir2
  257.    lv_dir1 = $lv_dir2
  258.    setwintitle Dir.gc '$lv_dir1                                    '
  259. endif
  260.  
  261. ;---------> ROUTINES
  262.  
  263. xRoutine OpenWindow        ; Routine to enlarge the window
  264.    setvar fm_mode 2
  265.    setgad Dir.gc 2 SHOW
  266.    setgad Dir.gc 10 SHOW
  267.    setgad Dir.gc 11 SHOW
  268.    setgad Dir.gc 12 SHOW
  269.    setgad Dir.gc 13 SHOW
  270.    setgad Dir.gc 14 SHOW
  271.    setgad Dir.gc 15 SHOW
  272.    setgad Dir.gc 16 SHOW
  273.    setgad Dir.gc 17 SHOW
  274.    changearg Dir.gc 21 4 <
  275.    changegad Dir.gc 0 -1 -1 400 200 ""
  276.    redraw Dir.gc
  277.    update Dir.gc 10 $lv_dir2
  278.  
  279. xRoutine CloseWindow        ; make it small again
  280.    setvar fm_mode 1
  281.    setgad Dir.gc 2 HIDE
  282.    setgad Dir.gc 10 HIDE
  283.    setgad Dir.gc 11 HIDE
  284.    setgad Dir.gc 12 HIDE
  285.    setgad Dir.gc 13 HIDE
  286.    setgad Dir.gc 14 HIDE
  287.    setgad Dir.gc 15 HIDE
  288.    setgad Dir.gc 16 HIDE
  289.    setgad Dir.gc 17 HIDE
  290.    changegad Dir.gc 0 -1 -1 200 200 ""
  291.    changearg Dir.gc 21 4 >
  292.    redraw Dir.gc
  293.  
  294.  
  295.  
  296.  
  297. RESIZE_BIG 154 11 226 250 dir.gc
  298.